package weekendhomework.homework02;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

public class Card {
    /*
        玩家人数
     */
    private Integer playerNum;

    /*
        玩家需要发多少张牌
     */
    private Integer cardNum;

    /*
        牌的花色
     */
    private String[] huaSe = {"红桃", "黑桃", "梅花", "方片"};

    /*
        牌的序号
     */
    private String[] paiValue = {"A", "2", "3", "4", "5", "6", "7", "8", "9", "10", "J", "Q", "K"};

    private List list;

    public Card(){}

    public Card(int playerNum, int cardNum){
        this.cardNum = cardNum;
        this.playerNum = playerNum;
        list = new ArrayList();

        for (int i = 0; i < huaSe.length; i++) {
            for (int j = 0; j < paiValue.length; j++) {
                list.add(huaSe[i] + paiValue[j]);
            }
        }
    }

    public void xiPai(){
        Collections.shuffle(list);
    }

    public void faPai(){
        int num = list.size();
        List a = list.subList(num - cardNum,num);
        System.out.println(a);
        a.clear();
    }
}
